import java.util.ArrayList;

public class TEst {
    public static void main1(String[] args) {
        ArrayList<Integer> arrayList=new ArrayList<>();
        arrayList.add(1);
        System.out.println(arrayList);
    }

    public static int missingNumber(int[] nums) {
        boolean[] flg=new boolean[nums.length+1];
        for(int i=0;i<nums.length;i++){
            flg[nums[i]]=true;
        }
        for (int i = 0; i < flg.length; i++) {
            if(flg[i]==false){
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] nums={1,2,3,4,0,6};
        System.out.println(missingNumber(nums));
    }
}
